package com.yc.auction.entity;

/**
 * 商品信息表
 * @author navy
 */
public class ProductInfo {
	private int pid; //商品编号
	private String pname; //商品名称
	private String des; //商品描述
	private double startPrice; //起拍价
	private double savePrice; //保留价
	private String beginDate; //起拍日期
	private String endDate; //结束日期
	private String pic; //商品图片
	
	private int flag;
	
	@Override
	public String toString() {
		return "ProductInfo [pid=" + pid + ", pname=" + pname + ", des=" + des
				+ ", startPrice=" + startPrice + ", savePrice=" + savePrice
				+ ", beginDate=" + beginDate + ", endDate=" + endDate
				+ ", pic=" + pic + "]";
	}
	
	public int getFlag() {
		return flag;
	}
	
	public void setFlag(int flag) {
		this.flag = flag;
	}

	public int getPid() {
		return pid;
	}

	public void setPid(int pid) {
		this.pid = pid;
	}

	public String getPname() {
		return pname;
	}

	public void setPname(String pname) {
		this.pname = pname;
	}

	public String getDes() {
		return des;
	}

	public void setDes(String des) {
		this.des = des;
	}

	public double getStartPrice() {
		return startPrice;
	}

	public void setStartPrice(double startPrice) {
		this.startPrice = startPrice;
	}

	public double getSavePrice() {
		return savePrice;
	}

	public void setSavePrice(double savePrice) {
		this.savePrice = savePrice;
	}

	public String getBeginDate() {
		if(beginDate!=null){
			return beginDate.substring(0,beginDate.lastIndexOf(" "));
		}
		return beginDate;
	}

	public void setBeginDate(String beginDate) {
		this.beginDate = beginDate;
	}

	public String getEndDate() {
		if(endDate!=null){
			return endDate.substring(0,endDate.lastIndexOf(" "));
		}
		return endDate;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}

	public String getPic() {
		return pic;
	}

	public void setPic(String pic) {
		this.pic = pic;
	}

	public ProductInfo(int pid, String pname, String des, double startPrice,
			double savePrice, String beginDate, String endDate, String pic) {
		super();
		this.pid = pid;
		this.pname = pname;
		this.des = des;
		this.startPrice = startPrice;
		this.savePrice = savePrice;
		this.beginDate = beginDate;
		this.endDate = endDate;
		this.pic = pic;
	}

	public ProductInfo() {
		super();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((beginDate == null) ? 0 : beginDate.hashCode());
		result = prime * result + ((des == null) ? 0 : des.hashCode());
		result = prime * result + ((endDate == null) ? 0 : endDate.hashCode());
		result = prime * result + ((pic == null) ? 0 : pic.hashCode());
		result = prime * result + pid;
		result = prime * result + ((pname == null) ? 0 : pname.hashCode());
		long temp;
		temp = Double.doubleToLongBits(savePrice);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits(startPrice);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ProductInfo other = (ProductInfo) obj;
		if (beginDate == null) {
			if (other.beginDate != null)
				return false;
		} else if (!beginDate.equals(other.beginDate))
			return false;
		if (des == null) {
			if (other.des != null)
				return false;
		} else if (!des.equals(other.des))
			return false;
		if (endDate == null) {
			if (other.endDate != null)
				return false;
		} else if (!endDate.equals(other.endDate))
			return false;
		if (pic == null) {
			if (other.pic != null)
				return false;
		} else if (!pic.equals(other.pic))
			return false;
		if (pid != other.pid)
			return false;
		if (pname == null) {
			if (other.pname != null)
				return false;
		} else if (!pname.equals(other.pname))
			return false;
		if (Double.doubleToLongBits(savePrice) != Double
				.doubleToLongBits(other.savePrice))
			return false;
		if (Double.doubleToLongBits(startPrice) != Double
				.doubleToLongBits(other.startPrice))
			return false;
		return true;
	}
}
